﻿using System;

namespace IndexerApplication
{
    class Employee
    {
        public string firstName;
        public string middleName;
        public string lastName;

        public string this[string index]
        {
            set
            {
                switch (index)
                {
                    case "a":
                        firstName = value;
                        break;
                    case "b":
                        middleName = value;
                        break;
                    case "c":
                        lastName = value;
                        break;
                    default:
                        throw new ArgumentOutOfRangeException("index");
                }
            }
            get
            {
                switch (index)
                {
                    case "a":
                        return firstName;
                    case "b":
                        return middleName;
                    case "c":
                        return lastName;
                    default:
                        throw new ArgumentOutOfRangeException("index");
                }
            }
        }

        static void Main(string[] args)
        {
            Employee ee = new Employee();
            
            ee.firstName = "胡";
            ee.middleName = "大";
            ee.lastName = "阳";

            Console.WriteLine("我的名字叫：{0}{1}{2}", ee["a"], ee["b"], ee["c"]);
            Console.ReadKey();

        }
    }
}